﻿<?php if(count($list_deal)>0){?>
<script type="text/javascript">
<!--
function add_cart(id_deal){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
											  document.getElementById('count_cart').innerHTML=xmlhttp.responseText;
											  alert("Đã thêm vào giỏ hàng");						 
										  }
									  }
	xmlhttp.open("GET","<?php echo base_url("home/add_cart")?>?id_deal="+id_deal,true);
	xmlhttp.send();
	
}
//-->
</script>
<div class="new_product">

    <div class="slide" align="center"> <a href="<?=base_url('deal_detail?did='.$list_deal[0]['id'])?>"><img src="<?php echo base_url($list_deal[0]['large_image']); ?>" width="633" height="100%" alt="chanhot.com" /></a> </div>
    
    <div class="info">
    
      <h2><a href="<?=base_url('deal_detail?did='.$list_deal[0]['id'])?>"><?=$list_deal[0]['name']?></a></h2>
      
      
      <p class="pt"><?php if($list_deal[0]['delivery']==0) echo 'Giao sản phẩm'; if($list_deal[0]['delivery']==1) echo 'Giao voucher'; ?></p>
      
      <p><?=$list_deal[0]['title']?></p>
      <p class="n_price"><?=number_format($list_deal[0]['price_sale_off'])?>đ</p>
      <a href="<?=base_url('deal_detail?did='.$list_deal[0]['id'])?>" class="n_view">Xem</a>
      <div class="orginal_price">
        <p class="or_price">Giá gốc: <span><?=number_format($list_deal[0]['price'])?>đ</span></p>
        <p class="percent">Giảm: <span><?=$list_deal[0]['sale_off']?>%</span></p>
      </div>
    </div>
  </div>
  <!-- end new product -->
  
  <ul class="list-product">
  	<?php foreach ($list_deal as $value){	?>
    <li class="artile">
    	<a href="<?=base_url('deal_detail?did='.$value['id'])?>">
      	<div class="cover-image" style="background-image:url(<?php echo base_url($value['small_image']); ?>)"><img src="<?php echo base_url($value['small_image']); ?>" width="281" height="281" alt="d" /></div>
      	 <h2><?=$value['name']?></h2>
       </a>
      <div class="article_info"> <a onclick="add_cart(<?=$value['id']?>)" style="cursor: pointer;" class="giohang" title="Thêm vào giỏ hàng"></a>
        <p class="art_price"><?=number_format($value['price_sale_off'])?>đ<span ><?php if($value['freeship']==1) echo 'Free Ship'; ?></span></p>
            <p class="view_person"><?=$value['count']?> người đã mua</p>
        <a href="<?=base_url('deal_detail?did='.$value['id'])?>" class="view_pro">Xem</a> </div>
      <div class="orginal_price orginal_price2">
        <p class="or_price">Giá gốc: <span><?=number_format($value['price'])?>đ</span></p>
            <p class="percent">Giảm: <span><?=$value['sale_off']?>%</span></p>
      </div>
    </li>
    <?php }?>
  </ul>
   <!-- <p class="view_more"><a href="#">Xem thêm</a></p>  -->
 <?php }?>